﻿@using CommonApp
@using BankApp.Models

@model CalcModel

@{
    ViewBag.Title = "Calculator";
}

<h2>Deposit Calculator</h2>

@using (@Html.BeginForm("Calculate", "DepositCalculator"))
{
    @Html.ValidationSummary(true)
    @Html.HiddenFor(m => m.CalcType)
    
    <b>
        @Html.Label(Model.CalcType.ToString() + ": ").If(Model.Solution != null)
        @Html.DisplayFor(m => m.Solution).If(Model.Solution != null)
    </b>
    
    <table>
        <tr>
            <td>@Html.LabelFor(m => m.PV).If(Model.CalcType != CalcType.PV)</td>
            <td>@Html.EditorFor(m => m.PV).If(Model.CalcType != CalcType.PV)</td>
            <td>@Html.ValidationMessageFor(m => m.PV).If(Model.CalcType != CalcType.PV)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(m => m.FV).If(Model.CalcType != CalcType.FV)  </td>
            <td>@Html.EditorFor(m => m.FV).If(Model.CalcType != CalcType.FV) </td>
            <td>@Html.ValidationMessageFor(m => m.FV).If(Model.CalcType != CalcType.FV) </td>
        </tr>
        <tr>
            <td>@Html.LabelFor(m => m.Rate).If(Model.CalcType != CalcType.Rate)</td>
            <td>@Html.EditorFor(m => m.Rate).If(Model.CalcType != CalcType.Rate)</td>
            <td>@Html.ValidationMessageFor(m => m.Rate).If(Model.CalcType != CalcType.Rate)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(m => m.Payment).If(Model.CalcType != CalcType.Payment)</td>
            <td>@Html.EditorFor(m => m.Payment).If(Model.CalcType != CalcType.Payment)</td>
            <td>@Html.ValidationMessageFor(m => m.Payment).If(Model.CalcType != CalcType.Payment)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(m => m.Period).If(Model.CalcType != CalcType.Period)</td>
            <td>@Html.EditorFor(m => m.Period).If(Model.CalcType != CalcType.Period)</td>
            <td>@Html.ValidationMessageFor(m => m.Period).If(Model.CalcType != CalcType.Period)</td>
        </tr>
        <tr>
            <td>@Html.LabelFor(m => m.Frequency)</td>
            <td>@Html.DropDownListFor(m => m.Frequency, HtmlHelpers.EnumToSelectList<IBS.Math.TVM.Frequency>().Where(_ => _.Text != IBS.Math.TVM.Frequency.None.ToString()))</td>
            <td>@Html.ValidationMessageFor(m => m.Frequency)</td>
        </tr>
    </table>
    
    <ul><input type="submit" class="button" value="Calculate" /></ul>
}
